package vis.items.visualItem;

import processing.core.PApplet;
import processing.core.PConstants;

public class TextObject extends VisualObject implements IVisualObject {

	private String text = "";

	public TextObject(PApplet root, IVisualObject parent) {
		super(root, parent);
		root.textAlign(PConstants.CENTER);
		root.textSize(30);

		adjustTextPosition();
	}

	// TODO minhvv other solution
	// try out to ajust location of text
	private void adjustTextPosition() {
		this.x += 30;
		this.y += 30;
	}

	public TextObject text(String text) {
		this.text = text;
		return this;
	}

	public String toString() {
		String s = super.toString();
		s += "{text=" + text + "}";
		return s;
	}

	@Override
	public void displayItself() {
		root.fill(color.getRed(), color.getGreen(), color.getBlue());
		{
			root.text(text, x + offsetX, y + offsetY);
			// root.text(text, x, y);
		}
		root.noFill();
	}
}
